package com.hualan.sfzyproject.controller;


import com.hualan.sfzyproject.domain.Notice;
import com.hualan.sfzyproject.service.NoticeService;
import com.hualan.sfzyproject.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/notice")
public class NoticeController {
    @Autowired
    private NoticeService noticeService;
    @GetMapping("/selectByUserId")
    public R selectByUserId(int userId, int pageNum, int pageSize){
        List<Notice> list = noticeService.selectByUserId(userId, pageNum, pageSize);
        if (list == null) {
            return R.error2("没有更多数据");
        }else{
            return R.ok(list);
        }
    }

    @PostMapping("/insertAll")
    public R insertAll(@RequestBody Notice record){
        int i = noticeService.insertAll(record);
        if (i == 1) {
            return R.ok("添加成功");
        }else{
            return R.error2("添加失败");
        }
    }
}
